home *** CD-ROM | disk | FTP | other *** search
- -- Video Time Slider
-
- -- Control
-
- -- requires an 'extent' cast member
- -- that limits the range the slider 'slides'
- -- controls the MovieTime of a video sprite,
- -- if the sprite is playing the slider moves automatically
-
-
-
- property pDuration, pMovieTime, VideoSprite
-
- property horizontal -- if false, vertical
- property extentSprite
- property hiliteMember -- looks like the handle plus hilite graphics
- -- also holds the member of handle while hilited
-
- property tracking
- property newLocH
- property newLocV
-
- property sending -- if true, sends value when parked
- property dynamic -- if true and sending true, sends value while tracking
- property style -- [sendAllSprites, SendSprite, Call]
- property addressee -- which spritenum gets the message if SendSprite or Call
- property name -- Sliders identity so messages can be traced
- property notify_list -- list of sprites to receive event, only has 1 item this time
-
- property min, max -- the range the slider maps to
- property valrange -- the difference of max and min, set on begin
- property minScreen, maxScreen -- calculated from the screen coords of the extent
- property currentScreenVal -- the data point in screen coords, set in tracking
- property extentlength -- in screen coords, set on begin
-
- property CurrentVal
-
- on getPropertyDescriptionList
- if the currentspritenum = 0 then
- set memdefault = 0
- else
- set memref = the member of sprite the currentspritenum
- set castlibnum = the castlibnum of memref
- set memdefault = member (the membernum of member memref + 1) of castlib castlibnum
- end if
-
-
- set description = [:]
-
- addprop description, #VideoSprite, [#default: 1, #format:#integer,¬
- #comment: "Video Sprite:"]
-
- addprop description, #extentSprite, [#default: 1, #format:#integer,¬
- #comment: "Extent Sprite:"]
-
- addprop description, #hiliteMember, [#default: memdefault , #format:#graphic,¬
- #comment: "Hilite Member:"]
-
- addprop description, #horizontal, [#default: 1, #format:#boolean,¬
- #comment: "Horizontal (if not vertical):"]
-
- addprop description, #dynamic, [#default: 1, #format:#boolean,¬
- #comment: "Dynamic:"]
-
- return description
- end
-
- on getBehaviorDescription
- return "Video Control Slider"
- end
-
- on compute_val me
- -- relies on tracking to update the currentScreenVal (different for Hor, Vert)
- set val = 0.0
- set val = float(the currentScreenVal of me) / float (the extentlength of me)
- set val = val * the valrange of me
- set val = val + the min of me
- return val
- end
-
- on send_the_val me, val
- -- sets the digital video time to the val * paramter {0 - movieduration}
- set pMovieTime = val * pDuration
- set the movieTime of sprite VideoSprite to pMovieTime
-
- end
-
-
- on beginSprite me
-
- set pDuration = the duration of sprite VideoSprite
-
- set the min of me = 0.0
- set the max of me = 1.0
- set the sending of me = true
-
- --
- set handle = the spritenum of me
- set the tracking of me = FALSE
- set the newLocH of me = the locH of sprite handle
- set the newLocV of me = the locV of sprite handle
-
- if the horizontal of me then
- set the newLocV of me = the locV of sprite the extentSprite of me
- set the minScreen of me = the left of sprite the extentSprite of me
- set the maxScreen of me = the right of sprite the extentSprite of me
- else -- vertical slider
- set the newLocH of me = the locH of sprite the extentSprite of me
- set the minScreen of me = the left of sprite the extentSprite of me
- set the maxScreen of me = the right of sprite the extentSprite of me
- end if
-
- puppetsprite handle, TRUE -- take this out when beginSpriteAutoPuppet fixed
-
- set the locH of sprite handle to the newLocH of me
- set the locV of sprite handle to the newLocV of me
-
- set the valrange of me = the max of me - the min of me
- set the extentlength of me = the maxScreen of me - the minScreen of me
-
- if the sending of me = FALSE then -- check for wrong input (dyn true, send false)
- set the dynamic of me = FALSE
- end if
-
- -- set CurrentVal = compute_val()
-
- end
-
- on prepareFrame me
- -- limits motion of handle to extents of extentSprite
- -- and locks the handle to the track of the extentSprite
-
- if tracking then
- set handle = the spriteNum of me
- set extent = the extentSprite of me
-
- if the horizontal of me then
- set the newLocH of me = the mouseH
- set the newLocV of me = the locV of sprite extent
- if the newLocH of me < the left of sprite extent then
- set the newLocH of me = the left of sprite extent
- end if
- if the newLocH of me > the right of sprite extent then
- set the newLocH of me = the right of sprite extent
- end if
-
- set the currentScreenVal of me = the newLocH of me - the minScreen of me
-
- else -- vertical slider
- set the newLocH of me = the locH of sprite extent
- set the newLocV of me = the mouseV
- if the newLocV of me < the top of sprite extent then
- set the newLocV of me = the top of sprite extent
- end if
- if the newLocV of me > the bottom of sprite extent then
- set the newLocV of me = the bottom of sprite extent
- end if
-
- set the currentScreenVal of me = the newLocV of me - the minScreen of me
-
- end if -- if vertical
-
- set the locH of sprite handle to the newLocH of me
- set the locV of sprite handle to the newLocV of me
-
- if the dynamic of me then
- send_the_val me, compute_val (me)
- end if
-
- else -- end if tracking, control slider position by movieTime
-
- set x = float(the movieTime of sprite VideoSprite)/ float(pDuration)
-
-
- set handle = the spriteNum of me
- set extent = the extentSprite of me
-
- if the horizontal of me then
- set ScreenX = the left of sprite extent + (x * (the right of sprite extent - the left of sprite extent))
- set the newLocH of me = screenX
- set the newLocV of me = the locV of sprite extent
- if the newLocH of me < the left of sprite extent then
- set the newLocH of me = the left of sprite extent
- end if
- if the newLocH of me > the right of sprite extent then
- set the newLocH of me = the right of sprite extent
- end if
-
- set the currentScreenVal of me = the newLocH of me - the minScreen of me
-
- else -- vertical slider
- set ScreenY = the top of sprite extent + (x * (the bottom of sprite extent - the top of sprite extent))
- set the newLocH of me = the locH of sprite extent
- set the newLocV of me = ScreenY
- if the newLocV of me < the top of sprite extent then
- set the newLocV of me = the top of sprite extent
- end if
- if the newLocV of me > the bottom of sprite extent then
- set the newLocV of me = the bottom of sprite extent
- end if
-
- set the currentScreenVal of me = the newLocV of me - the minScreen of me
-
- end if -- if vertical
-
- set the locH of sprite handle to the newLocH of me
- set the locV of sprite handle to the newLocV of me
-
- end if
-
-
- end
-
- on mouseDown me
- set tracking = TRUE
- set temp = the member of sprite the spritenum of me
- set the member of sprite the spritenum of me = member the hiliteMember of me
- set the hiliteMember of me = temp
- end
-
- on mouseUp me
- set tracking = FALSE
- set temp = the member of sprite the spritenum of me
- set the member of sprite the spritenum of me = member the hiliteMember of me
- set the hiliteMember of me = temp
-
- if the sending of me then
- set x = compute_val (me)
- send_the_val me, x
- end if
-
- end
-
- on mouseUpOutside me
- set tracking = FALSE
- set temp = the member of sprite the spritenum of me
- set the member of sprite the spritenum of me = member the hiliteMember of me
- set the hiliteMember of me = temp
-
- if the sending of me then
- set x = compute_val (me)
- send_the_val me, x
- end if
-
- end
-
- on mouseEnter me
-
- end
-
- on mouseLeave me
-
- end
-
-
-
-